-1

This is the current code:

import geopandas as gpd
from shapely.geometry import Polygon

lat_point_list = gdf['latitude']
lon_point_list = gdf['longitude']

polygon_geom = Polygon(zip(lon_point_list, lat_point_list))
crs = {'init': 'epsg:4326'}
polygon = gpd.GeoDataFrame(index=[0], crs=crs, geometry=[polygon_geom])       
print(polygon.geometry)

polygon.to_file(filename='polygon.geojson', driver='GeoJSON')
polygon.to_file(filename='polygon.shp', driver="ESRI Shapefile")

m = folium.Map([33.435598, -112.349602], zoom_start=5, tiles='cartodbpositron')
folium.GeoJson(polygon).add_to(m)
folium.LatLngPopup().add_to(m)
m

The map im getting is all over out of bounds:

Map

Could this be because of latitude, longitude mixed places? Thank you. In essence, the goal is to create a Choropleth map of US crime stats of cities(their bounds of coordinates.

komskisp
  • 67
  • 1
  • 5

1 Answers1

0

If plotting multiple points, you should use a MultiPoint, not a polygon. That way you don't get connecting lines between the points.

Looks a lot like your stats are not just for many US cities like you claim but also for many European cities and a few cities elsewhere.

Joooeey
  • 3,394
  • 1
  • 35
  • 49
  • Not sure why its rendering other continents, since all the coordinates where gathered by city name and state. – komskisp Dec 08 '21 at 16:53