correct GeoJSON format. map visualization - dictionary

First things first: is this data in proper GeoJSON format?
According to the definition of GeoJSON data, as you can see by the MultiPoint & coordinates, I think it is.
It looks like this:
{
"lang": {
"code": "en",
"conf": 1.0
},
"group": "JobServe",
"description": "Work with the data science team to build new products and integrate analytics\ninto existing workflows. Leverage big data solutions, advanced statistical\nmethods, and web apps. Coordinate with domain experts, IT operations, and\ndevelopers. Present to clients.\n\n * Coordinate the workflow of the data science team\n * Join a team of experts in big data, advanced analytics, and visualizat...",
"title": "Data Science Team Lead",
"url": "http://www.jobserve.com/us/en/search-jobs-in-Columbia,-Maryland,-USA/DATA-SCIENCE-TEAM-LEAD-99739A4618F8894B/",
"geo": {
"type": "MultiPoint",
"coordinates": [
[
-76.8582049,
39.2156213
]
]
},
"tags": [
"Job Board"
],
"spider": "jobserveNa",
"employmentType": [
"Unspecified"
],
"lastSeen": "2015-05-13T01:21:07.240000",
"jobLocation": [
"Columbia, Maryland, United States of America"
],
"identifier": "99739A4618F8894B",
"hiringOrganization": [
"Customer Relation Market Research Company"
],
"firstSeen": "2015-05-13T01:21:07+00:00"
},
I want to visualize this as a "zoomable",viz. interactive, map, as in the examples on the d3js website.
I'm trying to use a tool called mapshaper.org to see an initial visualization of the data in map form, but when I load it up, nothing happens.
To me this doesn't make sense because, according to their website, one can simply
Drag and drop or select a file to import.
Shapefile, GeoJSON and TopoJSON files and Zip archives are supported.
However, in my case it is not working.
Does anyone have any intuition as to what might be going wrong, or a suggestion as to a tool comparable to create a zoomable map out of GeoJSON data?

According to the definition of GeoJSON data, I have what I think constitutes data in that format
Well, you don't have a proper GeoJSON object. Just compare what you've got against the example you've linked. It doesn't even come close. That's why mapshaper doesn't know what to do with the JSON you load into it.
A GeoJSON object with the type "FeatureCollection" is a feature collection object. An object of type "FeatureCollection" must have a member with the name "features". The value corresponding to "features" is an array. Each element in the array is a feature object as defined above.
A feature collection looks like this:
{
"type": "FeatureCollection",
"features": [
// Array of features
]
}
http://geojson.org/geojson-spec.html#feature-collection-objects
A GeoJSON object with the type "Feature" is a feature object. A feature object must have a member with the name "geometry". The value of the geometry member is a geometry object as defined above or a JSON null value. A feature object must have a member with the name "properties". The value of the properties member is an object (any JSON object or a JSON null value). If a feature has a commonly used identifier, that identifier should be included as a member of the feature object with the name "id".
A feature looks like this:
{
"id": "Foo",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
},
"properties": {
"label": "My Foo"
}
}
http://geojson.org/geojson-spec.html#feature-objects
Here are examples of the different geometry objects a feature can support: http://geojson.org/geojson-spec.html#appendix-a-geometry-examples
Put those two together, it would look like this:
{
"type": "FeatureCollection",
"features": [{
"id": "Foo",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
},
"properties": {
"label": "My Foo"
}
},{
"id": "Bar",
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[100.0, 0.0],
[101.0, 1.0]
]
},
"properties": {
"label": "My Bar"
}
}]
}
That really doesn't look like the JSON you've posted. You'll need to convert that to proper GeoJSON somehow via a custom script or manually. It's a format i've never seen before, sorry to say.

Related

Can't get the desired properties via JsonPath evaluate method

I have a json schema that marks special properties in need of processing and I want to query those via JsonPath.Evaluate.
Here's a part of the schema to illustrate the issue
{
"type": "object",
"properties": {
"period": {
"description": "The period in which the rule applies",
"type": "object",
"properties": {
"start": {
"type": "string",
"format": "date-time"
},
"end": {
"type": "string",
"format": "date-time"
}
},
"required": [
"start"
],
"x-updateIndicatorProperties": [
"start"
]
},
"productType": {
"type": "string"
},
"x-updateIndicatorProperties": [
"productType"
]
}
}
I want to get the the JsonPath of the "x-updateIndicatorProperties" properties, so that I can then query the actual properties to process.
For this example, the expected result would be
[
"$['properties']['x-updateIndicatorProperties']",
"$['properties']['period']['x-updateIndicatorProperties']"
]
I've been trying for a while to get a JsonPath expression that would query these properties.
Currently I'm just iterating all properties and filter them manually :
"$..*"
I've also tried using :
$..['x-updateIndicatorProperties']
This works. But it returns a lot of duplicates. For the example above, I get 5 results instead of the expected 2. Can be demonstrated here : https://json-everything.net/json-path
Assuming I can't influence the schema itself, only the code that traverses it,
can anybody help with an expression to get the expected results or any other way to achieve the same outcome?
The stack is JsonPath 0.2.0, .net 6 and system.text.json.
This was a bug in the library when parsing paths that use a recursive descent (..) into a quoted-property-name selector (['foo']). So it would happen for any path in the form $..['foo'].
I've fixed the issue and released version 0.2.1.

How I can display additional information in my search result in the search box of my map

Is it possible to get the code of this map :
https://opengeo.tech/maps/leaflet-search/examples/multiple-layers.html
I want to know how in the search box, we can have the name and the type category of the name...
Thank you
If you want to get the code for any of the example maps, just go to the website for Leaflet.Control.Search's documentation and select one of the bundles to download from the "Download" section. Once it is downloaded, go to the examples dir and select the example you want to view. You can also view the files without downloading by going to the project's GitHub repo and selecting the examples dir there. Then, select the example you want to view.
To create the tooltip under the search bar that contains the name and type, you just need to do a few things. If you check in the bars data in the data dir inside of the examples dir, you can see that the name and type are being set in the example GeoJSON:
{
"type": "Feature",
"id": "node/500129236",
"properties": {
"#id": "node/500129236",
"addr:city": "Roma",
"addr:country": "IT",
"addr:housenumber": "5",
"addr:postcode": "00184",
"addr:street": "Piazza della Madonna dei Monti",
"amenity": "bar",
"name": "la Bottega del caffe'"
},
"geometry": {
"type": "Point",
"coordinates": [
12.4910927,
41.8950196
]
}
},
{
"type": "Feature",
"id": "node/560446888",
"properties": {
"#id": "node/560446888",
"amenity": "bar", <------- Establishment type
"name": "Marani". <------- Establishment name
},
"geometry": {
"type": "Point",
"coordinates": [
12.5132952,
41.8970607
]
}
}
Then in the code for the example you are provided, they have passed a buildTip function to the control instance that handles building that tooltip. If your data is set up the same way, you just pass the amenity and name to the function:
L.control.search({
layer: poiLayers,
initial: false,
propertyName: 'name',
// Function that returns the tooltip under the search bar:
buildTip: function(text, val) {
// Type from GeoJSON. If you changed it in GeoJSON, remember to change it here:
var type = val.layer.feature.properties.amenity;
// Returns html tooltip:
return ''+text+'<b>'+type+'</b>';
}
})
.addTo(map);
There are also more examples and more detailed information at the Leaflet.Control.Search GitHub Repo.

GeoJson : build a Polygon based on Point feature

Dear Stackoverflow team,
I'm impressed that after a bunch of hours digging the forum I still can't find any question/answer similar to my problem :
I have a GeoJson with a lot of Points features. I collect all Points (green in my example, see figure below) that follow some specification (distance between each of them)
Initial Data:
and I want to link all of them to build a Polygon (which represent an area).
What I'm looking for :
Or Solution accepted :
So I collect all coordinates from these Points, and to be sure the Polygon follows the GeoJson requirements, I'm using the "rewind" function
from geojson_rewind import rewind
But at the end, whatever I've tried I only get that kind of Polygon:
I probably don't use correctly the "rewind" function?
I'm looking for an (easy) automatic way to link all points together in a "convexion hull"
Thanks a lot for any help !
My initial coordinates are collected in a list :
[[4.3556672, 50.8538851], [4.3542534, 50.8546955], [4.3567798, 50.8547854], [4.3566527, 50.8541356], [4.3574286, 50.8552813], [4.3572234, 50.8551264], [4.3547752, 50.8545063], [4.3572736, 50.8560176], [4.3571226, 50.8546104]]
and the Polygon GeoJson I've managed to build, with the rewind function (recopying the last coordinates to get a Polygon) looks like that :
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
4.357223,
50.855126
],
[
4.35678,
50.854785
],
[
4.355667,
50.853885
],
[
4.356653,
50.854136
],
[
4.357123,
50.85461
],
[
4.354253,
50.854695
],
[
4.354775,
50.854506
],
[
4.357429,
50.855281
],
[
4.357274,
50.856018
],
[
4.357223,
50.855126
]
]
]
}
}
]
}
The shapely library is very useful for doing these kinds of geometric manipulations.
For generating a polygon of the convex hull of a set of geometries you can use object.convex_hull:
import shapely.geometry as sg
points = [[4.3556672, 50.8538851], [4.3542534, 50.8546955], [4.3567798, 50.8547854], [4.3566527, 50.8541356], [4.3574286, 50.8552813], [4.3572234, 50.8551264], [4.3547752, 50.8545063], [4.3572736, 50.8560176], [4.3571226, 50.8546104]]
polygon = sg.MultiPoint(points).convex_hull
Which results in the following shape:
Converting it into a GeoJSON with the help of shapely.geometry.mapping:
feature_collection = {
"type": "FeatureCollection",
"features": [
{"type": "Feature", "properties": {}, "geometry": sg.mapping(polygon)}
],
}
import json
geojson = json.dumps(feature_collection)

How to retrive full Wikidata info of an entity

I'm using different kind of queries to retrive wikidata info of an entity like, for Berlin:
https://www.wikidata.org/wiki/Special:EntityData/Q64.json
https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q64&format=json
but all of these did not include the full information.
As an example, i'm not able to find the official language or population data.
How can I get all data?
Both of the shown URLs / APIs do should you the full data for the entity that you are looking at, Q64 being Berlin.
In Wikidata the official language is represented by the Property P37 and the population by Property P1082.
You will find references to these properties in the JSON output.
For example for the language:
{
"mainsnak": {
"snaktype": "value",
"property": "P37",
"hash": "b8dce904caadeef339763625b903974aa4c83c6a",
"datavalue": {
"value": {
"entity-type": "item",
"numeric-id": 188,
"id": "Q188"
},
"type": "wikibase-entityid"
},
"datatype": "wikibase-item"
},
"type": "statement",
"id": "Q64$9AEBFCE4-EC53-4A97-B20B-4579FBD32CE7",
"rank": "normal"
}
This refers to Q188 which is German.

Get vertices with a simpler format

Is there a way to get a list of vertices with a simpler format?
Currently, the following query:
g.V().has(label, 'Quantity').has('text', '627 km');
returns an object like this:
{
"id": 42545168,
"label": "Quantity",
"type": "vertex",
"properties": {
"sentence": [
{
"id": "pkbgi-pbw28-745",
"value": "null"
}
],
"updated_text": [
{
"id": "pk9vm-pbw28-5j9",
"value": "627 km"
}
],[...]
And when I get a list of edges it is formatted in a simpler format:
g.E().has(label, 'locatedAt').has('out_entity_id','41573-41579');
returns:
{
"id": "ozfnt-ip8o-2mtx-g8vs",
"label": "locatedAt",
"type": "edge",
"inVLabel": "Location",
"outVLabel": "Location",
"inV": 758008,
"outV": 872520,
"properties": {
"sentence": "Bolloré is a corporation (société anonyme) with a Board of Directors whose registered offi ce is located at Odet, 29500 Ergué-Gabéric in France.",
"in_entity_id": "41544-41548",
"score": "0.795793",
"out_entity_id": "41573-41579"
}
}
How so?
Is there a way to get vertices formatted this way?
My advice is to rather than have your query return the whole vertex, return the specific properties that you are interested in. For example the vertex ID or some selected properties that you are interested in or a valueMap. Otherwise what you will get back is essentially everything. This is really the same as in SQL trying to not do a "select *" but selecting only what you really care about.
Edited to add an example that returns the IDs of matching vertices.
g.V().has(label, 'Quantity').has('text', '627 km').id().fold()
Will yield a result that looks like this
{"requestId":"73f40519-87c8-4037-a9fc-41be82b3b227","status":{"message":"","code":200,"attributes":{}},"result":{"data":[[20608,28920,32912,106744,123080,135200,139296,143464,143488,143560,151584,155688,155752,159784,188520,254016,282688,286968,311360,323832,348408,4344,835648,8336,1343616,12352]],"meta":{}}}

Resources