Reading in a file
So I have some geoplotting code within a python recipe. Something similar to this:
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
usa = world[world.name == "United States of America"]
# Plots
ax = world[world.name == 'United States of America'].plot(
color='white', edgecolor='black')
# We can now plot our ``GeoDataFrame``.
nothing_df.plot(ax=ax, color='red')
plt.show()
So I would like to read in and overlay a shapefile of my own instead of using the geopandas naturalearth_lowres file.
So I uploaded the shapefile and tried this: https://knowledge.dataiku.com/latest/kb/analytics-ml/geospatial/shapefiles.html, tho I think that is not what I want. I just want the raw shapefile.
So then I created a managed folder and tried to upload the shapefile from there and tried reading it in. The code looks similar to this:
handle = dataiku.Folder("shapefiles")
paths = handle.file_path("CA_Counties_TIGER2016.shp")
print(paths)
ca = gpd.read_file(paths)
ca.plot();
This gives me an error of:
CPLE_OpenFailedError: Unable to open /home/ubuntu/DATA_DIR/bucket/dataiku/DYNAMICDEPARTUREROUTING/JmYR0Zm2/CA_Counties_TIGER2016.shx or /home/ubuntu/DATA_DIR/bucket/dataiku/DYNAMICDEPARTUREROUTING/JmYR0Zm2/CA_Counties_TIGER2016.SHX. Set SHAPE_RESTORE_SHX config option to YES to restore or create it.
How do I get ahold of that managed file to pass it into geopandas?
Answers
-
I'm sorry I think I actually was grabbing the file correctly. I was missing another shapefile needed. My apologies.
-
tgb417 Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 1,598 Neuron
Welcome to the Dataiku Community. So pleased that you found your answer, and shared your question. I suspect that someone in the future will have a similar question. You have provided some insights on how you solved your problem.
Hope you are having a great day.