Comments (5)
v2 uses polylabel to correctly put markers inside polygons.
from nestwatcher.
I dug into this a little bit and currently this project is already using a library that utilizes that formula ( https://github.com/Toblerity/Shapely). While it isn't calling the polylabel
function directly it is indirectly getting the same polygon center point.
Tested with a few different values and really couldn't come up with a better solution than what is currently already implemented. It's possible two completely separate python developers implemented the initial project incorrectly...but it's much more likely mapbox's 2016 claim of "...guaranteeing the correct result in all cases." is false.
As it stands I have over 300 nests generated via this project and less than 15 of them have center points outside of the nest polygon. I stopped digging when I saw both libraries produced roughly the same results but sample code included below if anyone wants to look some more.
#pip install python-polylabel
#pip install shapely
#pip install geojson
from geojson import (
Feature,
FeatureCollection,
dumps
)
from polylabel import polylabel
from shapely.ops import polylabel as polylabel2
from shapely.geometry import shape
import json
NEST_NAMES = ['Foobar Park', 'Foobar2 Park', 'Foobar3 Park', 'Foobar4']
NEST_IDS = [605XXXX44]
with open("nests.json") as json_file:
json_data = json.load(json_file)
for item in json_data['features']:
if item['properties']['name'] in NEST_NAMES:
print(item['properties']['name'])
print(polylabel(item['geometry']['coordinates']))
print(polylabel2(shape(item['geometry']), tolerance=10))
if item['id'] in NEST_IDS:
print(polylabel(item['geometry']['coordinates']))
from nestwatcher.
Have you set the precision properly? The default precision is 1.0 which is probably not what you want.
from nestwatcher.
from geojson import (
Feature,
FeatureCollection,
dumps
)
from polylabel import polylabel
from shapely.ops import polylabel as polylabel2
from shapely.geometry import shape
import json
with open("nests.json") as json_file:
json_data = json.load(json_file)
for item in json_data['features']:
print(item['properties']['name'])
print(polylabel(item['geometry']['coordinates'], 1e-6))
point = polylabel2(shape(item['geometry']), tolerance=1e-6)
print(point)
assert shape(item['geometry']).contains(point)
print()
Changed precision/tolerance to 1e-6 (~0.1m). All the points are inside the polygon.
from nestwatcher.
Was this fixed?
from nestwatcher.
Related Issues (20)
- payload too large HOT 3
- Add Nest Report for Telegram HOT 2
- Timestamp Suggestion HOT 1
- Better Emoji handling
- Option to remove outdated nests from the DB
- Poracle Webhooks
- Docker-compose HOT 1
- Only Send Webhooks when nest is being updated HOT 1
- Missing Tags HOT 1
- error when all nests fall below min_avg
- 'ascii' codec can't decode byte 0xe2 in position 19376: ordinal not in range(128) HOT 2
- next_migration dts not working HOT 1
- tools.py option 3 not actually updating area_data json files HOT 1
- Event loop is closed HOT 1
- Creating emojis stuck HOT 3
- add a working discord link to the readme and wiki
- Maptiles not posting
- File "nests.py", line 181, in <module> with open(config.json_path, "w+") as file_: HOT 2
- Nest Migration Outdated
- -t or --hours Argument Not Working As Intended HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestwatcher.