Skip to content

Commit

Permalink
added sorting at concatenation of dataframes; moved initial sort to a…
Browse files Browse the repository at this point in the history
…fter geometry was added so that it aligned correctly
  • Loading branch information
jpswinski committed Aug 25, 2021
1 parent ef4dc85 commit b7fde0d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sliderule/icesat2.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,18 @@ def __todataframe(columns, delta_time_key="delta_time", lon_key="lon", lat_key="

# Create Pandas DataFrame object
df = geopandas.pd.DataFrame(columns)


# Build GeoDataFrame (default geometry is crs="EPSG:4326")
gdf = geopandas.GeoDataFrame(df, geometry=geometry)

# Set index (default is Timestamp), can add `verify_integrity=True` to check for duplicates
# Can do this during DataFrame creation, but this allows input argument for desired column
df.set_index(index_key, inplace=True)
gdf.set_index(index_key, inplace=True)

# Sort values for reproducible output despite async processing
df.sort_index(inplace=True)
gdf.sort_index(inplace=True)

# Build and Return GeoDataFrame (default geometry is crs="EPSG:4326")
gdf = geopandas.GeoDataFrame(df, geometry=geometry)
# Return GeoDataFrame
return gdf


Expand Down Expand Up @@ -461,7 +463,7 @@ def __parallelize(max_workers, block, function, parm, resources, *args):

# Return Results
if len(results) > 0:
return geopandas.pd.concat(results)
return geopandas.pd.concat(results, sort=True)
else:
return __emptyframe()

Expand Down

0 comments on commit b7fde0d

Please sign in to comment.