Reading in a file

fierstt
Level 1
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?

 

0 Kudos
2 Replies
fierstt
Level 1
Author

I'm sorry I think I actually was grabbing the file correctly.  I was missing another shapefile needed.  My apologies.

0 Kudos
tgb417

@fierstt 

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.  

--Tom
0 Kudos