An Industrial Think Tank Focused on Developing and Promoting AI Technology for Geospatial Applications [Please note this group was formed as an academic exercise for educational purposes and does not represent a real world organization]
MIT License
7
stars
3
forks
source link
Experiment with geoJson and Mapbox Static Tile API #146
We see in discussion #144 and hopefully with issue #145 that we can use mapbox to generate custom map tile sets.
Assessing custom tile sets may by setting custom training data for our map tile based classifiers. Access this data in a convenient web API through mapbox would be phenomenal! We can see play around with the mapbox API interactively using the MapBox Static Tile API Playground.
What's more we can see encouraging and wild functionality of the API such as:
accessing custom public styles
setting style filters (hmmm? the documentation isnt great)
and setting custom geoJson polygon overlays!
This is great! It is therefore possible that we can utilize the mapbox static tile API to access our own custom colored image tiles ( issue #144) as well asoverlay custom training/classification polygons directly in the API call! This could be super convenient for us as many polygon data exist (such as eelgrass extent data) which would provide a great deal of flexibility to how our classifiers are trained!
Note that we can easily generate geoJson polygons (which are a standard text representation of a geospatial polygon) using tools like geojson.io
Loading that generated geoJson string into the mapbox API playground, we can preview the results. You can try a custom style I made: mapbox://styles/rnsrg/ckn7p72f00fw418pdpbb8w3oc
For example: I have attempted the following demonstration API call - built using the API playground linked above.
note the entire coordinates of the polygon are inside the url!
Note: I've provided my own mapbox access token for the above link. This is generally not a good idea - these are meant to link your usage with the service and should not be made public. This token is however already in our code base and available. If the token gets abused I will have to reset it and perhaps remove it from the code base.
**So! You're mission: Create a new ipynb experiment in google colab which demonstrates a python function similar to our current getTile() function which uses this API schema to:
pull a tile of a given x,y,z (or a custom layer)
apply a geoJson polygon overlay
and open the file tile as a numpy array**
**note! it would be by far ideal if these tiles we called conformed to the locations of the slippy map convention Which we are currently using. The python package mercantile maybe useful in achieving this with the above API.
We see in discussion #144 and hopefully with issue #145 that we can use mapbox to generate custom map tile sets.
Assessing custom tile sets may by setting custom training data for our map tile based classifiers. Access this data in a convenient web API through mapbox would be phenomenal! We can see play around with the mapbox API interactively using the MapBox Static Tile API Playground.
What's more we can see encouraging and wild functionality of the API such as:
This is great! It is therefore possible that we can utilize the mapbox static tile API to access our own custom colored image tiles ( issue #144) as well as overlay custom training/classification polygons directly in the API call! This could be super convenient for us as many polygon data exist (such as eelgrass extent data) which would provide a great deal of flexibility to how our classifiers are trained!
Note that we can easily generate geoJson polygons (which are a standard text representation of a geospatial polygon) using tools like geojson.io
Loading that generated geoJson string into the mapbox API playground, we can preview the results. You can try a custom style I made:
mapbox://styles/rnsrg/ckn7p72f00fw418pdpbb8w3oc
For example: I have attempted the following demonstration API call - built using the API playground linked above. note the entire coordinates of the polygon are inside the url!
https://api.mapbox.com/styles/v1/rnsrg/ckn7p72f00fw418pdpbb8w3oc/static/geojson(%7B%22type%22%3A%22FeatureCollection%22%2C%22features%22%3A%5B%7B%22type%22%3A%22Feature%22%2C%22properties%22%3A%7B%7D%2C%22geometry%22%3A%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B-64.311%2C44.379%5D%2C%5B-64.311%2C44.377%5D%2C%5B-64.307%2C44.377%5D%2C%5B-64.3077%2C44.379%5D%2C%5B-64.311%2C44.379%5D%5D%5D%7D%7D%5D%7D)/-64.3077,44.3765,13,0/256x256?access_token=pk.eyJ1Ijoicm5zcmciLCJhIjoiZTA0NmIwY2ZkYWJmMGZmMTAwNDYyNzdmYzkyODQyNDkifQ.djD5YCQzikYGFBo8pwiaNA
Note: I've provided my own mapbox access token for the above link. This is generally not a good idea - these are meant to link your usage with the service and should not be made public. This token is however already in our code base and available. If the token gets abused I will have to reset it and perhaps remove it from the code base.
**So! You're mission: Create a new ipynb experiment in google colab which demonstrates a python function similar to our current getTile() function which uses this API schema to:
**note! it would be by far ideal if these tiles we called conformed to the locations of the slippy map convention Which we are currently using. The python package mercantile maybe useful in achieving this with the above API.