I'm using AnyLogic's new GIS capabilities, which in turn uses the OpenMap API. I want to figure out the area of each shapefile I'm using, each of which is represented by an AnyLogic ShapeGISMap.Layer that uses an OpenMap AreaShapeLayer (both of which I can play with). How do I calculate the area?
Only one way I can think of: Plot the content of your shapefile using a polyline (or some other AL markup element) and calculate its area using known syntax.
Otherwise, resort to some geo-processing tool such as ArcGIS :-(
Related
Is it possible to highlight rivers in Mapbox?
I would like to look at the world and see a list of specific rivers standing out as if highlighted with a yellow marker on a paper map. As I zoom in, the highlights would get more precise and ultimately coincide with the actual geometry of the rivers, or at least follow a line equidistant to their banks…
Is this at all possible?
I understand I can draw anything I want at specific geographic coordinates, but I can't figure out how to extract the river geometry from Mapbox to compute the paths for my highlighter strokes…
Or perhaps this kind of thing would be easier with another provider? How do people usually handle this kind of thing?
As far as I know there is not a way to highlight specific rivers in Mapbox's water related layers by an attribute like name. However, if you are looking to filter features based on size/prominence it is possible to filter features using the "class" or "type" property on the Mapbox waterway layer. This will at least allow you to filter/style features based on their type (i.e. river, stream, canal, etc...).
An alternative approach would be to pull together spatial data outside of the Mapbox platform and then bring it into Mapbox as your own tilset or dataset. I have done this before using the National Hydrography Dataset (this is just for the US) when I wanted to highlight specific rivers (i.e. only show the Rio Grande, Arkansas, and Colorado Rivers). I brought the NHD into my desktop GIS application (QGIS), filtered the features to just those rivers, exported the filtered features as GeoJSON and then uploaded to Mapbox and did all the desired styling in Mapbox Studio.
Hope this helps! I have been writing a series of guides for Mapbox that you might be interested in too. Here are some links:
The Mapbox Developer's Handbook
A Complete Guide to Sources and Layers in React and Mapbox GL JS
Here's something you can try:
Use the waterway line layer in the Mapbox Streets vector tileset and set a filter to show only the river feature type. This will show all rivers at low zoom levels, but because this is a line layer, it will not show the rivers' widths at high (close to the ground) zoom levels. Set the layer to 0 opacity at higher zoom levels so it disappears.
At higher zoom levels, you can use the water polygon layer in the Mapbox Streets vector tileset, but it includes oceans, rivers, lakes, ponds, reservoirs, and fountains all smashed into a simple polygon layer of undifferentiated, merged shapes:
there is no way to filter out or highlight specific water bodies or a partial subset of them.
If you want to isolate one specific waterway (like only the Rio Grande), you will need to import that data yourself as #tylerben suggests.
If you feel adventurous, you could try using mask in Turf.js to hide features in the water layer that are more than, say, ten miles from the centerline of a river from the waterway layer.
You can learn more about Mapbox map data in the core tilesets documentation.
If you look at the Google maps website, you can see that it accurately outlines a region (neigbourhood), giving you a pink shape that curves around the road. This means that Google has this data internally. If you use the Google Maps Developer API, however, it seems that you can only get a four-point boundaries object (NW, NE, SE, SW). If you then use this object to draw to, you basically get a rectangle.
Has anyone had this problem before and if so, how have you been able to get the detailed region info drawn on the map? Note that I'm trying to automate this as much as possible and I'm working in Saudi Arabia, where I don't think it's easy to get a third-party database of regional data.
You can download free shapefiles from many countries for example from here: http://www.diva-gis.org/gdata.
I am trying to retrieve a set of static map tiles from Google Maps using the simple web services API.
For zoom level 0, where there is only one tile, I simply specify the center as (0,0), which is trivial. (And yes, I am aware, that the south-north range is [-85.05113°,85.05113°] only, i. e. I have read about Mercator projection (not only the Wikipedia article).
So for zoom level 1 with 2×2 tiles I know that it'd be naive to think the central coordinates of the tiles would be (±90,±45). I applied one of the functions listed in above article's "Derivation of the Mercator projection" section. In PHP this looks like
function mercor($aLat) {
return rad2deg(asinh(tan(deg2rad($aLat))));
}
which always returns 50.498987 when passing in 45. I tried several of the alternative expressions :-) all with the same result, indeed, and even checked that value with a dedicated calculator.
Anyway, the value is obviously not correct, as you can see here (which was supposed to show the north west quadrant of the Earth's map, but here the equator is shifted to the north) (image source):
By trial and error I found the correct value to be close to 66.65, but I have no idea how to calculate that. I tried several manipulations of the R factor shown in the expressions in that mentioned "Derivation of the Mercator projection" section, and also fiddled with the "Scale factor" described in the same document, but whatever I do, I do not come close to 66.65.
Here you can see that 66.65 is the (close to) correct value, the equator at the bottom edge (image source):
And taking an illustration like, for example (image source):
and a tool like kruler, it also becomes obvious that it should be 66.65.
So, any idea would be greatly appreciated. Thanks in advance...
(Currently I'm trying it from withing HTML documents, because it's relatively simple, but later I'd like to do it from an environment in which I have no way to call JavaScript. so the JavaScript API is not an option.)
I have prepared a website describing the popular tiling system used behind Google Maps, OSM and similar slippy maps. Have a look at:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
With a click on the interactive map you receive bounds calculated in both the Mercator coordinates (in meters) as well as WGS84 lat/lon (in geodetic degrees).
Down on the page you find an open-source python code (which has been in the meanwhile ported to other programming languages by other people). This contains documented description of all the math you may need.
In fact, I have created this resource after working for Google SoC on the GDAL2Tiles/MapTiler project - which has been reimplemented into C/C++ and significantly improved and is now available via http://www.maptiler.com/.
UPDATE:
If you want to use the Google Maps Static API requests you may find useful another online tool which I prepared: http://www.maptiler.org/photoshop-google-maps-overlay-tiles/.
Feel free to review the JavaScript source code.
I'm trying to find an effective way to visualise feedback from some real-world sensors measuring wind speeds at various heights. Does anyone know if it's feasible to display 3D data in google maps?
I was imagining 3D arrows indicating direction and wind speed. If it's possible to load a model and position it to a particular GPS position / elevation and then change its orientation to point to a particular azimuth / elevation what could work.
Another alternative I was considering would be to create an image for each height and display the arrow by scaling / rotating the disk. The documentation suggests you could do a single layer at ground level with an overlay but doesn't make any mention of pulling those images up into the air.
I've played with google maps before, but not Google earth. Just trying to get a feel for what might be possible here. Has anyone tried anything like this?
Google maps is 2d and as such does not support 3d objects, things are located via a latitude and longitude only. However, you could easily create a '3d looking' image and incorporate it in to a map using the maps Api.
Google earth is 3d (latitude, longitude, altitude) and supports models and geometries loaded via kmz archives or constructed via the Api. It is fairly trivial to include using either method.
The reason you see no mention of 'pulling those images up into the air' in the doc you reference is because the document covers 'ground overlays' - so they are fixed to the ground...
Anyhow, take a look at the geometries and models section in the google earth api - should be exactly what you need.
http://code.google.com/apis/earth/documentation/geometries.html
http://earth-api-samples.googlecode.com/svn/trunk/examples/model.html
I have a client that want to have a web app I'm building for them display heat maps of the data.
I haven't worked with heat maps at all and I was wondering if anyone knew of some good tools for generating them.
Thanks.
Heat maps are often used in place of a more conventional term: kernel density estimators. If you need to compute these on the fly, consider GRASS GIS- specifically, the v.kernel or v.neighbors modules. These will generate a continuous estimate (i.e. raster surface) of density, at some target resolution (defined by the current region settings). GRASS GIS can be controlled via Python code, so it would be a simple matter to write a Python wrapper around the underlying modules, that could export the results to your web application.
For small datasets, the R project has several functions for reading/writing spatial data, and computing kernel density estimates.
I realize this is an old, old post -- but the next guy to stumble across this page might try gheat for heatmaps in webapps. There are ports for Django and Google App Engine, if you happen to be using those backends.
I'll assume this is data with three values per data-point - we'll call them x, y and z.
It would really help if x and y were spatial coordinates as that makes things easier.
Anyway, generate a bitmap of x by y (scaled appropriately).
For each x and y pair in the data, scale z to between 0 and 1 (or 0 and however many colours you have in your map), and plot z as a colour represented by that value.
E.g. a simple map could just use the R portion of RGB, in which case you'd have 256 graduations for your red.
Most likely, you'd want something more fancy, but you should be able to get the idea.
If your datapoints are spread apart, you can either plot them as rectangles that take up the space, or smoothly interpolate between them.
NOTE: THere is a web-based tool that does it here. I found it linked from the Wikipedia article on heatmaps. There's a java one too linked from there too.
If you want to generate heatmaps on the clientside (with JavaScript) I can recommend heatmap.js to you. It uses the HTML5 Canvas element to generate dynamic web heatmaps, you can new add data at any time and the heatmaps refresh.
Pyheat is another good library in python for building heatmaps.
Gheat is already mentioned in a reply by J.J.
I have a compelling heatmaps tool for both PC and mobile web pages to recommend: http://miapex.com
Might I suggest my own jQuery plugin?
jQuery Hottie makes it easy to take normal markup and add a background color like so:
<!-- Coloring elements is easy! -->
<ul id="example1">
<li>1<li>
<li>2<li>
<li>3<li>
<li>4<li>
<li>5<li>
</ul>
$('ul#example1 li').hottie();