Giter Club home page Giter Club logo

Comments (8)

murphy214 avatar murphy214 commented on July 17, 2024

There are some interesting things you could do with it i.e. things like jupyter widgets can help you build a gui for a dataset much easier than in js. Of course your paying for it in loading the dataset into memory every time.

You could also have something that just renders vector tiles from a data set (dataframe) passively but every time its updated the changes will effect the rendering, a configuration like this would give you more control over different zoom levels and rendering density. Just some thoughts!

Also I'll probably have a read_geojson method for nlgeojson to read directly from a geojson data source to a nlgeojson dataframe easily and I think it should be pretty quick as well! Currently writing that now!

from mapboxgl-jupyter.

ryanbaumann avatar ryanbaumann commented on July 17, 2024

@murphy214 great notes.

Also I'll probably have a read_geojson method for nlgeojson to read directly from a geojson data source to a nlgeojson dataframe easily and I think it should be pretty quick as well! Currently writing that now!

Can you share this when it's ready? Would love to incorporate this.

from mapboxgl-jupyter.

murphy214 avatar murphy214 commented on July 17, 2024

@ryanbaumann
Here's the new repo, I gave an example in the read me: https://github.com/murphy214/nlgeojson

There is a chance the install could fail I tested on a vm but I'm actually using compiled golang executables to read the geojson in parallel , and I'm sure there are corner cases that aren't supported however its like 30x faster reading in and you get nlgeojson dfs in the process.

I'm essentially reading chunks and stitching geojson feature pieces back together see here so I'm sure there that if you have a field with '{' or '}' in it its gonna fail, but like I said kind of just hack right now.

EDIT I lied its not 30x faster that was a random guess heres the bench I just ran 120k linestrings and like 50 features properties.

import geopandas as gpd
import nlgeojson as nl
import time

s = time.time()
nl.read_geojson('wv.geojson')
print time.time() - s
# 10.4603159428 s

s = time.time()
gpd.read_file('wv.geojson')
print time.time() - s
# 105.153828859 s

Of course one should remember that these dataframes don't have their spatial context within them in other words geometric operations aren't ready to be done on them but they can be, and in most instances (9/10) we don't need the shapely geos implementation as its super heavy and if we are doing a spatial operation its more performant on a domain specific data structure not arbitrary features in memory (bringing them in and out of memory when needed).

from mapboxgl-jupyter.

ryanbaumann avatar ryanbaumann commented on July 17, 2024

@murphy214 just tested nlgeojson - it works great! A simple architecture, for now, is just to use nlgeojson to export a data frame to a local geojson file very fast, and then load the local geojson file in the mapboxgl viz.

Here's an example with 380k earthquake points as a heatmap from the USGS API:

from mapboxgl-jupyter.

murphy214 avatar murphy214 commented on July 17, 2024

@ryanbaumann Great! Glad it ended up working! It should be quite a bit faster than putting it a normal json serializer/deserializer and it also shouldn't be so ram intensive as well! I really need to build out the read functionality a little more robustly to account for corner cases of "{}" in strings like a real json parser, because I think it could pretty useful to some people.

Any ideas for incorporations with polygons and/or linestrings? You could always do some UI side filter stuff with Jupyter widgets and it should be entirely possible, however, it probably would be better to handle stuff like that natively in JS.

from mapboxgl-jupyter.

ryanbaumann avatar ryanbaumann commented on July 17, 2024

Agree it could be a very useful utility library @murphy214. A few things I'm thinking to add:

  1. Ability to pass a list of dataframe column names to include in an exported geojson.
  2. Remove latitude and longitude from geojson properties since they're already included in the geometry.

Re: Lines and Polygons - That's next on the agenda for this library to offer an easy Pythonic interface for analysts to create choropleths maps. As for sliders and filters - that should be easier to add as render-time filters and style changes with HTML objects. Mapboxgl is really good at changing data style each frame. Along with the new Mapboxgl expression syntax, we should be able to handle all the data updates in the viz alone after loading the data once and creating vector tiles.

from mapboxgl-jupyter.

murphy214 avatar murphy214 commented on July 17, 2024

@ryanbaumann This could be done with minimal refactoring I'll take a look at implementing it tomorrow as I'm currently off for the holidays, it shouldn't take to long! I'll keep you posted!

from mapboxgl-jupyter.

ryanbaumann avatar ryanbaumann commented on July 17, 2024

Modified df_to_geojson() utility function to output a line-delimited geojson file. 4cb4ef3

Serving the exported geojson file locally using the Jupyter Notebook web server works great for all default visualizations. It can be optimized from here, but this is a solid starting point for v 1.0

from mapboxgl-jupyter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.