Hi Stackoverflow people,
I am working on an organisation registration, in which orgs can register their project areas (like all Nevada, entire US, or simply a city e.g. Boston) and users should find all organisations which are covered by the organisation according to their lat & lng.
What is the best way to connect the organisation information with the user searches?
Is the following process ok or do you have any suggestions:
I load the shapefiles of all necessary states, counties , etc. in
my postgis database
If an organisation adds "New York state" to
their coverage area, I would look up the polygon shape for the state
(or the id to the shape) and save it in my coverage table
When I search for the org coverage, I would find all projects where the
user lat & lng is part of
Is that process above ok to connect the user information to the shapefile information?
How can I look up polygons in the shape files? Can I reference them with an ID?
How would the lookup work with cities, since most lists with city name, lat, lng only list the center point of the city? Or is there a table for even city boundaries?
Thank you for your help and suggestions!
When you import a shp file to postgis with shp2pgsql, all the other columns (state name, city name, etc) are imported too, so you can search by name or any other property that the shp file has, or you can search by geometry, if you have a point and you want to search polygons or points(citys in your case) near that point, the query to the database is very simple:
SELECT * from myTable where ST_DWithin(users_point, the_geom, 0.002);
//the distance units of ST_DWithin are in the geometry units.
PS shp2pgsql automatically creates a serial column(unique id)
Related
So far I have this code:
with open("real estate data.csv", "a") as myfile:
myfile.write('"{0}",'.format((tweets.user.location).encode('utf8')))
Which can find me the location of users on the Twitter API when they make a Tweet.
However, it returns broad locations such as New York, but what if I wanted to find specific cities or areas, like Times Square, New York instead of all of New York.
The latitude and longitude coordinates are specified under the coordinates field, however those coordinates are only specified in case the user explicitly shared their location while tweeting.
To access it simply use tweet.coordinates, here is an example:
"coordinates":[-97.51087576,35.46500176]
Read more about coordinates in the doc.
This used to be part of the geo field which is deprecated now so it will always be equal to null.
Read more about how geolocation works within the Twitter API here.
I have a Stream Analytics job that generates locations latitude and longitude to powerbi. I am trying to create a map on powerbi.com from these locations. I am creating a map diagram and adding latitude and longitude fields to maps latitude and longitude fields. But nothing is generated. It is expecting some Location field as well. What data should I provide there?
Yes. You need something in the Location field (but it can be a timestamp or an ID or anything). That's what decides how many bubbles you have. Then for each bubble it does an average latitude and longitude to determine where to put the bubble.
The location field is to specify a "City" location rather then specifying it giving coordinates. If you provide "London" for instance it will create the shapes at the center of London as defined in the maps provider.
On the Long and Lat side, they have to be in a specific format for PBi to recognize them as map fields.
Take a look at the links below for further info on how to change the data type using the editor.
http://community.powerbi.com/t5/Desktop/How-to-map-latitude-longitude/td-p/2479
http://www.radacad.com/how-to-do-power-bi-mapping-with-latitude-and-longitude-only
Hope this helps.
I like to develop a shopping cart website with multiple products.
(ex.: mobile phone, furniture etc.,)
here mobile phone specification will cover
size of display
memory
operating system
camera etc.,
but for furniture - its specification is entirely different from above electronic product.
type of wood
color
weight
shape
glass or mat finish etc.,
My question is: how to handle a common database-table for product specification ?
each & every category of product & its spec will be differ - so how to have a common
table ProductSpecificationTable ?
I searched many site including google.. but cant able to get the perfect soultion.
Please help me to move to next step.
Ask yourself the question: How can I accomplish this kind of database? First of all you need products.. Every product has to be in some kind of category and every category has to have his own properties. So, you've to create a product table with unique id and every product needs a category id. At this moment it is time to link from your property table to your category table(by id) and to set the values you need a 'property_value' table.
**table:** **id**
product --> category id
property --> category_id
property_value --> property_id
I hope you will understand my explanation otherwise just ask :)
You can add 1 more table to accomplish that. Table that contains cat_id, product_id and the property. That is a many to many relationship. I believe this way you can accomplish thst.
You can achieve this with a single table within a database but that will complicate the CRUD operations over the table. So I will recommend you to create one database like ‘Inventory’ which can have multiple tables (one table for each of the Product Type).
First Table could be list of Product Types you have (mobile phones, accessories, furniture):
You can use this table to populate your list of items available. Here the column _table_name will contain the actual name of the Tables.
Then for each of the product you can have different tables with different number of columns:
Table for Product Type Mobile Phones:
Table for Product Type Furniture:
I hope this will help.
I'm trying to create a Django app that would take an inputted address and return a list of political races that person would vote in. I have maps of all the districts (PDFs). And I know that I can use geopy to convert an inputted address into coordinates. How do I define the voter districts in Django so that I can run a query to see what districts those coordinates fall in?
This is a non-trivial problem too large in scope to answer in specific detail here. In short, you'll need to use GeoDjango (part of contrib). There is a section dedicated to importing spatial data.
Once you have your data loaded, you can use spatial lookups to find what district a particular coordinate intersects.
As to where to get the voter district data, you might start with www.data.gov's geodata catalog.
I'm trying to use Yahoo's excellent GeoPlanet API:
http://developer.yahoo.com/geo/geoplanet/guide/api-reference.html
I would like to pick a random town from anywhere in the world but can't see an easy way to do it. I have tried querying by country and asking for children of type 'town', but can't seem to do that directly.
Can anyone think of a way to pluck out a random town WOEID without having to query the country, then the admin regions, then the admin 2, then the admin 3 etc.
I have also experimented using YQL, but don't have enough of an understanding about the available APIs.
Have a look at http://world-gazetteer.com/.
You can store all towns in your local database, then do random select, and then just geocode selected town using any geocode service you like.
Just for phun, why not generate random lat/long & display whatever is there?