PostGis WKT format of Multipolygon is:
MULTIPOLYGON(
((20.229 39.409,20.2241 39.401,20.220 39.410,20.229 39.409)),
((20.209 39.407,20.223 39.400,20.211 39.402,20.209 39.4076))
)
Google Maps api v3 Polygon is:
var triangleCoords = [
new google.maps.LatLng(25.774252, -80.190262),
new google.maps.LatLng(18.466465, -66.118292),
new google.maps.LatLng(32.321384, -64.75737)
];
The question is:
Can i create a multipolygon in google maps?
PostGIS supports a number of output formats directly:
http://postgis.refractions.net/documentation/manual-1.5/ch08.html
See the ST_As() funcs.
The Google Maps API supports a number of these as well (SVG, KML, etc.). You should try using a format that both speak. Now I'm not sure if Google Maps accepts multipolygons in any of these formats. But you could always use the ST_Simplify() func.
var multipolygon=[
[new google.maps.LatLng(x1,y1),new google.maps.LatLng(x2,y2),new google.maps.LatLng(x3,y3)],
.
.
.
[new google.maps.LatLng(x4,y4),new google.maps.LatLng(x5,y5),new google.maps.LatLng(x6,y6)]
];
This is a little old, but I was just working on the same thing, trying to create MultiPolygons from GeoJSON files in Google Maps, so thought I would share.
Basically, no, you can't. But you can create a workaround.
First create something to manage the individual sub-polygons (object, array, etc). Then populate that object with each portion of the multipolygon. Then you can treat the sub-polygons as a group, via custom methods or iteration through them.
See http://www.alecbennett.com/projects/loadgeojson for a quick demo of "MultiPolygon" highlighting on hover in Google Maps v3. Data is loaded from a GeoJSON file, so would be a similar approach to the WKT version.
Related
Using Google Sheets, I am trying to retrieve text passages from the Perseus Scaife Library, which has a working API.
When I query for the document node (=importxml("https://scaife-cts.perseus.org/api/cts?request=GetPassage&urn=urn:cts:greekLit:tlg0527.tlg001.opp-grc2:1.1","/")) I get all the data, including the URNs etc. However, any other xpath_query gives an error.
I know that Google Sheets can access the data, but I would like to be able to select only one node (//p).
You want to retrieve the text in passage. If my understanding is correct, how about this answer?
=importxml(A1, "//*[local-name()='passage']")
Result :
Note :
https://scaife-cts.perseus.org/api/cts?request=GetPassage&urn=urn:cts:greekLit:tlg0527.tlg001.opp-grc2:1.1 is converted by URL encode and put to "A1".
Converted URL is https://scaife-cts.perseus.org/api/cts?request=GetPassage&urn=urn%3acts%3agreekLit%3atlg0527%2etlg001%2eopp%2dgrc2%3a1%2e1.
Reference :
local-name
If this was not what you want, I'm sorry.
I would like to know how I can filter to detect numbers (integers) only? e.g 1,2,....,10. Currently the api detects all formats of "text".
You should do that processing on your side. Use Regex to filter out numbers from string received from Vision API:
str="Text received 123,0";
number = str.replace(/\D/g,'');
result: 123
Google vision API will detect all character, google vision does not
have separate API(which can detect only number at the point of
scanning) for only numbers till now, But after scanning the image
using google vision api we will get the text in response example
"23XA3783", so now we can replace the character we don't want.
Store the google api response in temp variable
source_str = "23XA3783"
In my case I get the required string from google api response using
js
source_str= temp["responses"][0].textAnnotations[0].description
final_output = source_str.replace(/\D/g,'');
I need to store the data presented in the graphs on the Google Ngram website. For example, I want to store the occurences of "it's" as a percentage from 1800-2008, as presented in the following link: https://books.google.com/ngrams/graph?content=it%27s&year_start=1800&year_end=2008&corpus=0&smoothing=3&share=&direct_url=t1%3B%2Cit%27s%3B%2Cc0.
The data I want is the data you're able to scroll over on the graph. How can I extract this for about 140 different terms (e.g. "it's", "they're", "she's", etc.)?
econpy wrote a nice little module in Python that you can use through a command-line interface.
For your "it's" example, you would need to type this command in a terminal / windows console:
python getngrams.py it's -startYear=1800 -endYear=2008 -corpus=eng_2009 -smoothing=3
This will automatically save the query result in a CSV file named after your query parameters.
econpy's package, in #HugoMailhot's answer, no longer works (2021) and seems not maintained.
Here's a updated version, with some improvements for easier integration into Python code:
https://gitlab.com/cpbl/google-ngrams
You can call this from the command line (as in econpy's) to create a CSV file, e.g.
getngrams.py it's -startYear=1800 -endYear=2008 -corpus=eng_2009 -smoothing=3
or call it from python to get (and plot) data directly in python, e.g.:
from getngrams import ngrams
df = ngrams('bells and whistles -startYear=1900 -endYear=2018 -smoothing=2')
df.plot()
The xkcd functionality is still there too.
(Issues / bug fix pull requests /etc welcome there)
So I need to transfer information from a file. An example of the heading is label=1234 I was hoping I could use a perl code to change "label" to "id", is this possible?
Cy.js supports JSON data. Convert or write your data to JSON, and you can load it in as described in the docs: http://cytoscape.github.io/cytoscape.js/
I have a URL that returns data in CSV format. I would like to use Google Vizualization to create an interactive chart of the data. I've looked at several examples on Google Chart and Vizualization web page but I'm a bit confused as I'm not familiar with JavaScript or web programming in general.
Question: Do I have to use JavaScript to parse the CSV string myself and manually construct the DataTable with addColumn() and addRows()? Or, is there a way to simply pass the CSV url to the charting function? I'm hoping to do something like this:
var csv_data = get_data_from_url('http://...')
var data = new google.visualization.DataTable(csv_data);
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, ...);
Can someone please help me out?
Thanks.
Yeah, it looks like they're using JSON or some close variant of JSON for the data. You could try a CSV to JSON converter. Apparently converting CSV to JSON is a fairly trivial operation, requiring only a few lines of code:
converting CSV/XLS to JSON?