शुरू करेंमुफ़्त में शुरू करें

Spatial join और counts निकालना

आप geopandas choropleth प्लॉट करने की तैयारी जारी रखेंगे। इसके लिए council districts के साथ spatial join करके building permits का एक GeoDataFrame बनाएँगे। इसके बाद, आप प्रत्येक council district में जारी किए गए building permits की गिनती निकाल पाएँगे।

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में Geospatial Data का Visualization

पाठ्यक्रम देखें

अभ्यास निर्देश

  • permits, council_districts.crs, और permits की geometry से permits_geo बनाएँ।
  • permits_geo और council_districts का spatial join करें ताकि हर council district के within आने वाले building permits मिलें। इसे permits_by_district कहें।
  • हर district में permits की गिनती, permit_counts, groupby() और size() methods को chain करके निकालें।
  • permit_counts से counts_df बनाएँ। Index reset करें, और कॉलम के नाम district और bldg_permits रखें।

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Create permits_geo
permits_geo = gpd.GeoDataFrame(____, crs = ____.____, geometry = ____.____)

# Spatially join permits_geo and council_districts
permits_by_district = gpd.sjoin(____, ____, ____ = ____)
print(permits_by_district.head(2))

# Count permits in each district
permit_counts = permits_by_district.____(____).____()

# Convert permit_counts to a df with 2 columns: district and bldg_permits
counts_df = ____.to_frame()
counts_df = counts_df.____()
counts_df.____ = ['district', 'bldg_permits']
print(counts_df.head(2))
कोड संपादित करें और चलाएँ