Osmnx: Removing sidewalk from one side of the street - python-2.7

I am trying to plot a simplified map for pedestrians in my university campus using Osmnx library with python 2.7.
So far, I have this Image of the plot and as you can see, it is plotting sidewalks on both sides of the street. I was planning on removing one side of the sidewalks from this.
However I'm confused what logic to approach this with?
So far, I have created a custom filter to plot only footways
custom_walk = ('["area"!~"yes"]["highway"="footway"]["foot"!~"no"]["service"!~"private"]{}').format(ox.settings.default_access)
G = ox.graph_from_bbox(top, bottom,right, left, custom_filter= custom_walk)
ox.plot_graph(G_projected,save = True,filename = "maps", show = False,node_size=5,node_color='#FFFFFF',node_edgecolor='#FFFFFF',edge_color='#cccccc',bgcolor = "#000000",node_zorder=3,dpi=300, edge_linewidth=5,use_geom=True)
ox.simplify.clean_intersections(G,tolerance=100)
What I am trying to understand is does Osmnx have relations for footways in a way that will tell me their relative position to the nearest street (if they are on the east or the north side of the street (that way I can keep a standard on what sidewalks are visible)? Or if there is a simpler logic at this?
Thanks!

What I am trying to understand is does Osmnx have relations for footways in a way that will tell me their relative position to the nearest street (if they are on the east or the north side of the street (that way I can keep a standard on what sidewalks are visible)? Or if there is a simpler logic at this?
The answer is no, OSMnx doesn't know where the sidewalk is in relation to the nearest street. One option might be to just identify the sidewalk edges you don't want, make a list of their OSM IDs, then remove them from the graph.

Related

Semantic Intelligence with python

I am trying to classify words into a score, the scoring for now is to be very simple in that I just want to classify words based on -1, 0, 1 and sum the scores at the end. This classification would be based on the emotional connotation of the word so positive words like "great,awesome,excellent" would receive score of +1 and negative words like "bad, ill, not" would receive score of -1 and neutral words would receive 0 . For example;text = "I feel bad" would be pushed through a table,DB,library in which words were pre-classied and would summed into "I(0) + feel(0) + bad(-1) = -1
I have gone ahead and as an example stripped a website of its HTML coding using BeautifulSoup and urllib libraries (code below):
import urllib
from bs4 import BeautifulSoup
url = "http://www.greenovergrey.com/living-walls/what-are-living-walls.php"
html = urllib.urlopen(url).read()
soup = BeautifulSoup(html)
# kill all script and style elements
for script in soup(["script", "style"]):
script.extract() # rip it out
# get text
text = soup.get_text()
# break into lines and remove leading and trailing space on each
lines = (line.strip() for line in text.splitlines())
# break multi-headlines into a line each
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
# drop blank lines
text = '\n'.join(chunk for chunk in chunks if chunk)
print(text)
Output:
What are Living Walls? Definition of Green Wall and Vertical Garden
GREEN OVER CREY
Overview
/
What are living walls
/
Our green wall system vs. modular boxes
What are living walls
L iving walls or green walls are self sufficient vertical gardens that are attached to the exterior or interior of a building. They differ from green façades (e.g. ivy walls) in that the plants root in a structural support which is fastened to the wall itself. The plants receive water and nutrients from within the vertical support instead of from the ground.
The Green over Grey™ living wall system is different than others on the market today. It closely mimics nature and allows plants to grow to their full potential, without limitations. It is also by far the lightest.
Diversity is the key and by utilizing hundreds of different types of plants we create striking patterns and unique designs. We achieve this by utilizing the multitude of colours, textures and sizes that nature provides. Our system accommodates flowering perennials, beautiful foliage plants, ground covers and even allows for bushes, shrubs, and small trees!
Living walls are also referred to as green walls, vertical gardens or in French, mur végétal. The French botanist and artist Patrick Blanc was a pioneer by creating
the first vertical garden over 30 years ago.
Our system
consists of a frame, waterproof panels, an automatic irrigation system, special materials, lights when needed and of course plants. The frame is built in front of a pre existing wall and attached at various points; there is no damage done to the building. Waterproof panels are mounted to the frame; these are rigid and provide structural support. There is a layer of air between the building and the panels which enables the building to breath. This adds beneficial insulating properties and acts like rain-screening to protect the building envelop.
Our green walls are low maintenance thanks to an automatic irrigation system
my question is what would be the best way to run this string through a table or library of pre classified words and would anyone know of any existing libraries of preclassified words based on emotion? how can I create a small table or DB to test with really quick?
Thank you all in advance,
Rusty
If you have such a table you can find a list of such lexicons here: http://mpqa.cs.pitt.edu/lexicons/effect_lexicon/
You could load that list on a dictionary and perform the algorithm you describe. However, if you are looking for quick results, I recommend you use textblob library. It's very easy to use and it has a lot of features. A very nice place to start in a project like what you might be starting.
I dont know how to mark this question as a duplicate, but a quick google search turned this up.
The first answer looks promising. I went to the link and it just requires some information to access the file. I assume it would be in a format that is straightforward to parse.

How to turn zipcode into coordinates with geodjango?

I am having trouble understanding the documentation on geodjango. First of all using the zipcode example:
class Zipcode(models.Model):
code = models.CharField(max_length=5)
poly = models.PolygonField()
objects = models.GeoManager()
Is PolygonField where I would store the actual long/lattitude coordinates of the zipcode? The other question is how would I actually translate the zipcode into those coordinates? That is the one step I cannot figure out how to do.
I assume I'm going to need to convert the zipcode into coordinates and then compare those against other coordinates to determine 'nearest zipcodes to location x', which is what I'm trying to do.
On a side note, I found https://github.com/coderholic/django-cities, which seems like I would be able to accomplish this WITHOUT converting zipcodes into coordinates, but there isn't really any documentation, so I have no idea.
GeoDjango does not handle converting zip codes into locations: that's simply not what it's for. You'll need a geocoding library, a Google search should reveal plenty.
The project you link to simply uses an existing set of geocoded data for cities and zip codes, and even tells you where to get it - see the relevant management command.

highlight buildings based on value and show in browser

I want to build a website with a map based on openstreetmap that colors buildings based on a their potential average annual yield of solar power. I have the energy data for individual houses.
My question is now, can I assign each house (identified by street name and number) a value and the house can then be colored based on this value in the browser?
I have little to no experience with openstreetmap and would be happy about hints into the right direction.
So you need a OSM dataset and filter it for building=* ways to get the building outlines (e.g. with osmosis). Then you do create a second run to filter for addr:= tags of nodes and merge them with the building outlines from step 1. Be aware of conflicts and that one building can have multiple addresses. So now you have a dataset with normalized addresses and need to create a lookup structure like hashmap to get a mapping for your solar data: addr:street x addr:housenumber -> building id
(very raw idea on how to do it)
IMHO the mixing of external datasources to the copyleft open database license makes that you need to relicense your dataset also under ODbL.
Also keep in mind that not every address is currently at OSM and the existing ones can be wrong!

SAS gmap and label centering

I have a Problem where I could not find an easy solution and I am looking for some ideas or tipps.
I am working with SAS on a project which result should be a map of europe, where the countries get colored after a certain algorithm. I use the maps.europe data and the %annomac and %maplabel macros to label the countries.
This works pretty fine, except for Portugal and Spain - because theese countries have island far away from the coastside, the calculated centroid from %maplabel of the country is not in the center of the country:
Unfortunately I just can cut portugal completely out of the map but not the Islands
I have tried already this method:
Try to cut the parts of the map via gproject which contains the islands - this delievered unexplaniable results to me (just showing some parts of europe, even if I set the parameters extremly wide)
and now I am a bit stuck.
I already thought about this ideas:
Comnbining the map.europe with the map.spain and and map.portugal where I delete the islands before, but I am not sure how to do that that the labeling and all still works for theese combined data.
Is it possible to set the label points for portugal and spain manually and overwrite the data from the %maplabel macro?
Or is there an even easier solution?
Thanks for your help and best regards
stephan
I'm not familiar with those macros, but given how GMAP works, I would indeed override the annotate dataset. You may want to read up on how annotate datasets work, but in general:
The GMAP statement will have an option, annotate= and some dataset. Find that dataset, let's say it's called ANNODS.
Then look at that dataset. Identify a row that has function=text and label=PORTUGAL. That is the row you need to modify the x/y coordinates of in order to move the label around (x1 and y1). You might need to play around with this some to get the right coordinates.
Then run the PROC GMAP, and you should have a newly moved-over Portugal.

How can I Implement Yelp's Map Search and Search by zip code or by city name

How can I implement yelp like search?
There are 2 types of searches on yelp.
Simple search using the zip code, city and state in U.S.
I'm using PostgreSQL and wonder if there is good dataset that I can use that has city, state and zip code. I was hoping to find a good geo shape file and use geoDjango where I can just use, say Store.objects.filter(coordinates__in=cityNameORZipCode).
There seem to be some zip code database that I can use, but I really don't know where I can find a good city, state. The last option is to create my own cityname and state table and link to Stores, but not sure if this is smart thing to do.....hm.
Yelp has map search.
If you zoom in or out the google map, it searches local businesses according to the map area you are viewing. Think this is amazing. How can I do this?
It's looking dark right now. Please shed me some light.
You're asking a very broad and unanswerable question, but a good place to start for data in the U.S. is at the Census Bureau. For example:
State and State Equivalent Areas
County and County Equivalent Areas
The full list:
http://www.census.gov/geo/www/cob/bdy_files.html