Google Project Sunroof

Looks like Google is starting to calculate solar information on their building data.  They started Project Sunroof to make installing solar panels easy and understandable for anyone by calculating the best solar plan.

Does that sound familiar?  It should since LA County has done that already with their Solar Map.

When you enter an address, Project Sunroof looks up the address in Google Maps and combines the map data with other databases to create a personalized roof analysis.  They compute how much sunlight hits your roof using their 3D building models, shadows cast by nearby structures and trees, sun positions over the year, and historical cloud and temp patterns.  They then recommend an installation size for your roof and reference local solar providers.

Currently Project Sunroof only covers Boston where the Sunroof Team is, the San Francisco Bay area where Google is, and Fresno … where one of the engineer’s mom lives.

Once they figure out the LA area, it will be interesting to compare it to LA County’s Solar Map information.

Take a look at the short video and visit the Project Sunroof website for more info.

googlesunroof

Extracting Features from Map Services

UPDATE 3/28/2018: See Extracting MORE Features from Map Services to get around the maximum record count limit.

ArcGIS Server map services are a pretty cool thing.  Someone else is providing GIS data for you to consume in a map or application.  And if they keep it up to date over time, even better.

However, there are some times when you just need the data instead so you can edit/manipulate it for your GIS analysis needs.  If you cannot acquire a shapefile or geodatabase, there is a way to extract the features from a map service.

For you to extract the features, there must be three things in place:

  • You must have access to the REST interface for the map service
  • The layer in the map service that you want must be a feature layer
  • The layer must have a query option with JSON format supported

To demonstrate this, let’s head on over to the map services provided by Southern California Association of Governments (SCAG).  Specifically, the one for city boundaries:

http://maps.scag.ca.gov/scaggis/rest/services/City_Boundaries/MapServer

Since we have access to the REST interface, we can check out the different settings of the map service.  Note there are two layers, City Boundaries (layer 0) and County Boundaries (layer 1).

extract1

We are interested in the City Boundaries layer, so click on it.  This brings up detailed information about the data.

extract2

They were good to include when the data was updated in the Description.  Also note that it is a feature layer and we can query it.  If you scroll down to the bottom you will see the query option in the Supported Operations section.

extract3

Also listed at the bottom are the fields associated with the features.  We should take a look at these next to see what fields we want.  To do this, go back to the previous page and then click on the ArcGIS.com Map option in the View In section at the top:

extract4

This will open up a default map on ArcGIS Online and display the map service layers.

extract5

Click on City Boundaries to view the two layers, then click on the icon that looks like a spreadsheet just below the City Boundaries layer.

extract6

This will bring up the attribute table for the city boundaries.

extract7

After taking a look at the data, all I want are the CITY, ACRES, and COUNTY fields.

Now let’s go back to the REST interface for the City Boundaries layer.  Take a look at the MaxRecordCount setting.  It is set to 1000.  This means that only 1000 records (features) can be returned for each query.  This can be extra work for you if this map service has more than 1000 features.  We need to find out how many features there are.  To do this, scroll to the bottom and click on the Query link in the Supported Operations section.  This will bring up the query interface for the map service.  This allows you to do a lot with the map service and get different results.  I will not go into the details of each parameter.  You can find out more info about them from the ArcGIS REST API reference.  For now, just enter “1=1” (without the quotes) in the Where input field.

extract8

This is a little trick to return as many records as we can.  Also make sure to set Return Geometry to False and Return Count only to True.  With Return Count only set to True, we will actually get all records (an exeption to the MaxRecordCount setting).  Once those are set, click the Query (GET) button at the bottom of the query form.  It looks like nothing happened, but scroll down to the bottom to see the result.

extract9

Note the count is 191.  So we don’t have to be concerned with the 1000 record limit.  We will be able to grab all the features at once.

NOTE: For those of you that are curious about the query, take a look at the URL in your web browser.  This is the REST query syntax used to get the record count.  We will be using something similar in a Python script to extract the actual geometry of all features.  You can mess around with the query form to see what happens and the URL that is created to make that happen.

We will be using a Python script to extract the features from the map service and create a featureset in a geodatabase.  Here is the script:

import arcpy

arcpy.env.overwriteOutput = True

baseURL = "http://maps.scag.ca.gov/scaggis/rest/services/City_Boundaries/MapServer/0/query"
where = "1=1"
fields = "CITY,ACRES,COUNTY"

query = "?where={}&outFields={}&returnGeometry=true&f=json".format(where, fields)

fsURL = baseURL + query

fs = arcpy.FeatureSet()
fs.load(fsURL)

arcpy.CopyFeatures_management(fs, "H:/scag/data.gdb/city_boundaries")

So what does this do?  First it loads the arcpy module and sets the overwrite option to True in case we want to run it again and overwrite the featureset.  A baseURL variable is set to the query URL of the city boundaries map service, a where variable for our where clause for the query, and a fields variable with a comma delimited list of the fields that we want.

Next a query variable is set with the actual query needed to extract the features.  Note the query is in quotes with {} for values that are plugged in by the variables listed in format() at the end.  Also note the returnGeometry parameter is set to true and f (for response format) is set to json.  What this query will do is extract all the records with just the fields we want, return all the geometry (the polygons), and output the whole thing in JSON format.  With the baseURL and query variables set, we merge them together for one long query URL as the fsURL variable.

Finally, we create an empty featureset (the fs variable), load the returned JSON data from the map service query into it, then copy it as a featureset to our geodatabase.

It takes a second or two to run the script.  Check out the result!

extract10

And here are the attributes we wanted for all 191 records.

extract11

I do want to point out that the data you get will be in the same projection as the map service.  You can find out what projection the map service is in by looking at the Spatial Reference setting in the REST interface.  Note this map service is using 26911:

extract12

What the heck is that?  Go over to spatialreference.org and enter the number in the search field.  It will tell you this is the NAD83 UTM zone 11N projection.  If you wanted something else, like NAD83 California State Plane zone 5 US feet (2229), you would edit the Python script to include the output spatial reference parameter in your query, like this: “&outSR=2229”.  The data is projected on the fly for you and saved to your geodatabase!

I hope this helps you out when you are looking for data in map services.  -mike

2015 ESRI User Conference Workshop Takeaways

After attending a few workshops on ArcGIS Pro and ArcGIS Sever today, here are a few things that I noted and thought you all might find interesting.  If you work on the bleeding edge, you probably already know!

ArcGIS Pro

  1. Uses Python 3.4, full Python is not included, however SciPy and Pandas libraries are included.
  2. Because ArcGIS Pro uses Python 3.4, some of your Python scripts that you created for ArcGIS Desktop, which uses Python 2.7, might not work.  There is a script checker in Pro that will tell you if any lines of code will fail.  For example, printing a variable using the line “print x” must be “print(x)” in Python 3.4.
  3. At version 1.2, Pro will have concurrent use licenses.

ArcGIS Server

  1. Version 10.3 now has service usage statistics, which includes total requests, average response times, and timeouts.  You can create reports at the service, folder, and site level.
  2. You can preserve layer IDs so they don’t change when you republish a map service that has new layers in it.  There is an option in the Layer properties in ArcMap to turn this feature on.  You can also change the layer ID for your different layers before you publish to a map service.
  3. Server has expanded Linux support.  Now works with redhat, SUSE, CentOS, Scientific Linux, and Oracle Linux.

2015 ESRI User Conference Plenary

For those of you that arrived in San Diego on Sunday, you were greeted by a downpour of rain that lasted into the night. However, that all cleared up today for the 36th Annual ESRI User Conference.

esriuc2015

During this morning’s Plenary Session, Jack emphasized the “Geography Everywhere” theme and touched on the usual things like web GIS and sharing data. Really there were few surprises. However, they did have a cute little skit about all their apps, posing like individuals in a dating service to get your attention to use them. It was a different way of showing you all the choices you have when it came to apps.  You can even vote for your favorite app here.

Here are a few new announcements that might be of interest:

  1. Vector tiles, finally!
  2. New Workforce/Dispatcher, Workforce/Mobile, and Navigator apps that will work with Collector
  3. New AppStudio for ArcGIS that will help you build your own native apps in Android, iOS, Windows, and Linux
  4. ArcGIS Earth, full KML file support
  5. New drone app
  6. Statistical and scientific packages like R and SciPy will be able to run directly as geoprocessing tools/scripts in ArcGIS
  7. ArcGIS for home use licensing will now extend to the entire ArcGIS product, not just Desktop
  8. Expect ArcGIS 10.4 and Pro 1.2 in Winter 2016

I would suspect that ESRI will have the Plenary Session video online sometime today. I will update this post when it becomes available for you to watch at home! -mike

4:25pm update:  Click here for today’s videos.

Disneyland’s 60th Anniversary Tomorrow

This year in July will be Disneyland’s 60th anniversary.  Disneyland opened on July 17, 1955 in Anaheim California and was the only theme park designed and built under the direction of Walt Disney.

Opening day was broadcast live by ABC (one of the investors and joint owner of Disneyland) and was hosted by three of Walt’s friends: Art Linkletter, Bob Commings, and Ronald Reagan.  About 28,000 people visited the park.  Watch the whole thing below!

Believe it or not, Disneyland was built in 7 months before opening day!  Also, Tomorrowland construction was delayed and was put together in the last 2 months!  Before building began, Walt Disney was insightful to place towers around the area to film time-lapse movies during the construction.  Check out this video of one of the film reels.  It is really cool to see what that area of Anaheim looked like before Disneyland was built.

When guests entered the park, they were given little guides that told them about all the attractions at Disneyland.  Check out this 1958 guide and maps.

disneyland58

I like in the Tomorrowland section there is a caption that reads “The colorful Avenue of Flags marks the entrance to Tomorrowland, the world of 1987”.  I don’t remember 1987 looking like that!

Note no Monorail, Matterhorn, or Submarine Voyage.  Those came in the summer of 1959.  Check out this insert that was placed in the guides.

disneyland59

If you plan on visiting Disneyland tomorrow on anniversary day … all I can say is good luck to you and stay sane!