![]() ![]() To do it in Python, just run the follwoing command: # Convert CRS to WGS 84 (lat and long in degrees) In order to properly display the new data in a visualization platform like MapBox, dataframe needs to be converted into WGS-84 CRS. The resulting geodataframe has has each row representing single geometry in the form of POLYGON object, with height information derived from Z value of POLYGON Z and same properties for all polygons belonging to the same building. New_gdf = gpd.GeoDataFrame(feature_list, index=range(len(feature_list)), crs=crs) # Create a GeoDataFrame from new features New_feature = Polygon( for vertex in polygon]) # Assign new feature's height and vertices # Create new feature and assign properties to each Polygon # Flatten MultiPolygons into list of Polygons # Iterate through features of GeoDataFrame # Extract Coordinate Reference System (CRS) of the GeoDataFrame ![]() In order to create MapBox friendly 3D dataset, we basically need to extract each of the nested Polygons as an individual one, assign common properties (identifiers etc.), define its height based on Z value of its vertices and store vertices in format. |- coordinates - list of Polygons, each containing list of building vertices in format |- properties - all of the attributes stored in GDF columns Each feature have the following attributes: |- id - database unique identifier ![]() We can see it is a FeatureCollection with a list of features. Let’s convert gdf into JSON to explore further the structure of the file. Geometry: Building shape of `POLYGON Z` type. SOURCE_ID: Building shape source identifier. Assigned by City Planning.ĭOITT_ID: Unique identifier assigned by DOITT. NYC 3-D Building Model contains the following information: BIN: Building identification number. Let’s inspect the geodataframe with gdf.head(): Gdf = gpd.read_file(gdb_path, driver='FileGDB', layer=0) Or if data is in a GeoDataBase format: import fiona Now let’s load data into GeoDataFrame: gdf = gpd.read_file('>.shp') To start we have to import necessary libraries, which are: JSON, GeoPandas and Shapely. In order to work I needed to somehow decompose this nested collection of polygons and tease out height value. It requires plain 2D polygons defined by XY coordinates and assigned height information, which then can be used as an extrusion value. The only problem is that MapBox does not support Multipatches with XYZ coordinates. A collection that can be made up of triangle strips, triangle fans, triangles, or rings, multipatch features can be used to construct 3D features in ArcGIS®, save existing data, and exchange data with other non-GIS 3D software packages such as Collaborative Design Activity (COLLADA) and SketchUp®. The multipatch data format, a geographic information system (GIS) industry standard developed by ESRI in 1997, is a geometry used as a boundary representation for 3D objects. In this case we decided to build our own city model which could be extruded by MapBoxGL engine.Īs a basis for our model I chose NYC 3-D Building Model provided by NYC DOITT. ![]() The only problem was that, we needed to edit and interact with this layer in our tool. Especialy, that MapBox introduced extrusions to display building heights ( here is tutorial). Since we were already using eneterprise account of Carto as a data server and MapBox as a visualization platform (BTW, they are pretty nicely integrated), we decided to stick with it. There were already existing efforts trying to accomplish just that such as CesjumJS or OSMBuildings. While working on NYC Energy & Water Performance Map for NYC Mayor’s Office of Sustainaility we thought that it would be cool to display actual building shape in 3D rather than just the plain footprint outline. ![]()
0 Comments
Leave a Reply. |