Robert Lowe

Plotting traffic camera locations in Hong Kong with GeoPandas

leave a comment »

Recently I’ve had cause to work with geospatial data in Amazon SageMaker and needed a way to visualise the results. I’ll write more about SageMaker itself in a future post. In this post I aim to summarise a bit of what I learned about working with geospatial data in Python, in particular using GeoPandas.

I created a Jupyter Notebook that demonstrates how to use GeoPandas to load a set of points, in this case locations of traffic cameras in Hong Kong (as it happens, from the same dataset I used to create this), and layer them on top of a shapefile representing a map of the 18 districts of Hong Kong, resulting in a visualisation such as the one below.

The complete source code is available on GitHub.

Using Amazon SageMaker Notebooks

This code will run in any Jupyter environment. I used an Amazon SageMaker Notebook, as described below. Amazon SageMaker is part of AWS, so you will need an AWS account to follow this approach.

Start by navigating to Amazon SageMaker in the AWS console. In the Amazon SageMaker menu, under Notebook, select Notebook instances.

On the Notebook instances page, click Create notebook instance.

Under Notebook instance settings, give your instance a name.

Under Permissions and encryption, if you don’t already have a SageMaker role, choose Create a new role under IAM role. The role defaults should be fine as the notebook doesn’t require any special permissions. Under Root access select Enable – Give users root access to the notebook.

Under Git repositories, choose Clone a public Git repository to this notebook instance only. Under Git repository URL, enter the URL of the repository, which is https://github.com/rmlowe/traffic-cameras-geopandas.git.

Alternatively, you could fork this repository, and then add the forked repository to your Amazon SageMaker account. That allows you to associate credentials with the repository in SageMaker, so you can push changes back up to the forked repository.

You can leave other settings at their default values, and click Create notebook instance.

It might take a few minutes for the instance to start. Once the instance is started, click on the instance name under Notebook instances, then click on either Open Jupyter or Open JupyterLab to access the notebook. (I recommend using JupyterLab since it has out-of-the-box integration with git.)

Written by rmlowe

August 5, 2019 at 11:59 pm

Posted in Uncategorized

Navy Pier

leave a comment »

Taken just before some self-important security guy shouted at me to get back behind the railings.

Navy Pier

Written by rmlowe

September 26, 2012 at 1:30 am

Posted in Photos, Travel

As Pretty as an Airport: TPE

with 2 comments

Sunset from Terminal 2 of Taiwan Taoyuan International Airport, taken shortly before boarding our flight back to Hong Kong.

TPE

Written by rmlowe

September 17, 2012 at 3:11 am

Jingtong revisited

leave a comment »

Taken just after the sun disappeared behind the mountains, and just before we were due to catch the train back to Taipei Station via Rueifang.

Jingtong

Written by rmlowe

September 14, 2012 at 8:08 am

Posted in Jingtong, Photos, Taiwan, Travel

Victoria Harbour at Dusk

leave a comment »

Bonnie and I took the Star Ferry to Tsim Sha Tsui for dinner this evening. As we crossed Victoria Harbour we could see this awesome sunset towards Lantau Island. I couldn’t take multiple exposures from the moving ferry, so as soon as we docked I rushed off the boat and took this from the pier.

This was taken handheld as I didn’t have my tripod with me.

Victoria Harbour at Dusk

Written by rmlowe

August 22, 2011 at 1:23 am

Posted in Hong Kong, Photos

Dragon boats, Sai Kung

leave a comment »

I just had this shot lined up on the tripod when a couple of women and their dogs strolled into the frame.

I took a couple of shots and then waited patiently for them to leave. Unfortunately the tide was coming in somewhat faster than I realized, so by the time they left my tripod and I were standing in a couple of inches of water.

Afterwards I removed my waterlogged shoes and we strolled back to Sai Kung Town to find some flip-flops. But I ended up liking one of the first shots—taken whilst standing on dry land—best anyway.

Dragon boats, Sai Kung

Written by rmlowe

June 6, 2011 at 6:41 am

Posted in Hong Kong, Photos

Jingtong

leave a comment »

Jingtong is the last stop on the Pingxi Line (平溪線). Originally built by the Japanese to transport coal, the railroad now mainly serves day-trippers looking to explore the lush gorges and waterfalls of the Keelung River, and the derelict remains of the former industry.

Jingtong

Written by rmlowe

May 29, 2011 at 11:50 pm

Posted in Jingtong, Photos, Taiwan, Travel